package com.hz.house.controller;

import com.hz.house.bean.entity.SellManScoreBean;
import com.hz.house.bean.vo.SellManTemplateMsg;
import com.hz.house.enums.SellManScoreEnum;
import com.hz.house.service.RedisCacheDataService;
import com.hz.house.service.SellManScoreService;
import com.hz.house.service.SellManService;
import com.hz.house.service.WxgzhSellHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

//@Api("测试")
@RestController
@RequestMapping("/test")
public class TestController {

	
	@Autowired
	private RedisCacheDataService cacheService;
	
	@Autowired
	private SellManScoreService sellManScoreService;
	
	@Autowired
	private WxgzhSellHouseService wxgzhSellHouseService;
	
	@Autowired
	private SellManService sellManService;
	
	@RequestMapping("/uid")
	public Object testUserid() {
		
		
		return cacheService.getIncrementUserId();
	}
	
	
	@GetMapping("/addscore")
	public Object testAddScore(Integer cid) {
		
		SellManScoreBean s = new SellManScoreBean();
		s.setCreateDate(new Date());
		s.setCustomerId(cid);
		s.setSellManCustomerId(10026486);
//		s.setDate(DaysIntUtil.getDays(new Date()));
		s.setScore(SellManScoreEnum.SHARE_ARTICLE.getOnceScore());
		s.setScoreId(SellManScoreEnum.SHARE_ARTICLE.getId());
		sellManScoreService.addScoreOnShare(s);
		return "ok";
	}
	
	@GetMapping("/testMsg")
	public Object testSendMsg() {
		//oBF-DuCtP9NV1f-S6l3kuq0n4F24
		//{"touser":"oBF-DuCtP9NV1f-S6l3kuq0n4F24",
		//"data":{"keyword3":{"color":"#173177","value":"川发天府上城"},
		//"keyword4":{"color":"#173177","value":"2019-11-14 15:44:22"},
		//"keyword1":{"color":"#173177","value":"刘副文"},
		//"keyword2":{"color":"#173177","value":"18782982792"},
		//"remark":{"color":"#173177","value":"点击本消息跳转到买房好帮手立即回复客户咨询!"},
		//"first":{"color":"#173177","value":"有意向客户咨询您的楼盘"}},
		//"template_id":"35GLThNocp9bgxLhhEgs6dPNc1eqnjXSGapV-GiR8xE",
		//"miniprogram":{"pagepath":"pages/tabBar/home/main","appid":"wx4d4b24ddf6c6fb04"}}
		SellManTemplateMsg x = new SellManTemplateMsg();
		x.setBuildingName("川发天府上城");
		x.setCustomerId(10011657);
		x.setFromUserName("刘副文");
		x.setFromUserTel("18782982792");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		x.setZiXunTime(sdf.format(new Date()));
		wxgzhSellHouseService.sendTemplateMsgZiXunTongZhi("oBF-DuCtP9NV1f-S6l3kuq0n4F24", x);
		return "ok";
	}
	
	@RequestMapping("/testYs")
	public Object testYesterdayStar() {
		this.cacheService.deleteSellManShareLimitCache(this.sellManService.getAllSellManIds());
		return "ok";
	}
}
